@model IEnumerable<IdentityRole>

@{ 
    ViewBag.Title = "角色列表";
}


    <h1>所有的角色列表信息</h1>

     @if (Model.Any())
     {
        <a class="btn btn-primary mb-3" style="width:auto" asp-action="createRole" asp-controller="Admin" >添加角色</a>

         foreach (var role in Model)
         {
<div class="card mb-3">

    <div class=" card-header">角色ID：@role.Id</div>
    <div class="card-body">

        <h5 class="card-title">@role.Name</h5>

    </div>


    @using Microsoft.AspNetCore.Authorization

    @inject IAuthorizationService authorizationService;




    <div class="card-footer">
        <form method="post" asp-action="DeleteRole" asp-route-id="@role.Id">

            @if ((await authorizationService.AuthorizeAsync(User, "EditRolePolicy")).Succeeded)
            {
                <a asp-controller="Admin" asp-action="EditRole" asp-route-id="@role.Id" class="btn btn-primary">编辑</a>

            }
            @*<a asp-controller="Admin" asp-action="EditRole" asp-route-id="@role.Id" class="btn btn-primary">编辑</a>*@


            <span id="confirmDeleteSpan_@role.Id" style="display:none">
                <span>你确定你要删除？</span>
                <button type="submit" class="btn btn-danger">是</button>
                <a href="#" class="btn btn-primary" onclick="confirmDelete('@role.Id', false)">否</a>
            </span>
            <span id="deleteSpan_@role.Id">
                <a href="#" class="btn btn-danger" onclick="confirmDelete('@role.Id', true)">删除</a>
            </span>
        </form>
        


    </div>
     

</div>
         }


     }
     else
     {

<div class=" card">
    <div class="card-header">

        尚未创建任何角色信息
    </div>
    <div class="card-body">

        <h5 class="card-title">点击下面的按钮创建角色</h5>

    </div>
    <div class="card-footer">

        <a  asp-controller="admin" asp-action="createrole" class="btn btn-primary">创建角色</a>
        


    </div>
</div>


     }


@section Scripts{ 
    <script src="~/js/CustomerScript.js" asp-append-version="true"></script>
}